<?php

namespace app\common\model;

use think\Model;


class Funds extends Model
{

    

    

    // 表名
    protected $name = 'funds';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'create_time_text'
    ];
	
	
	
	const OPE_TYPE_PLUS = 1;
	const OPE_TYPE_LESS = 2;
	
	public static $operationTypeList = [
		self::OPE_TYPE_PLUS => '添加',
		self::OPE_TYPE_LESS => '减少'
	];
	
	
	const ACCOUNT_TYPE_BALANCE = 1;
	const ACCOUNT_TYPE_INTEGRAL = 2;
	
	public static $accountTypeList = [
		self::ACCOUNT_TYPE_BALANCE => '余额',
		self::ACCOUNT_TYPE_INTEGRAL => '积分',
	];
	
	
	
	const TYPE_WITHDRAW = 1;
	const TYPE_PAY_ORDER = 2;
	const TYPE_REBATE = 3;
	const TYPE_ADMIN_OPERATE = 4;
	const TYPE_WITHDRAE_BACK = 5;
	const TYPE_VIEW_COMISSION = 6;
	
	public static $typeList = [
		self::TYPE_WITHDRAW => '提现',
		self::TYPE_PAY_ORDER => '支付订单',
		self::TYPE_REBATE => '销售奖励',
		self::TYPE_ADMIN_OPERATE => '后台操作',
		self::TYPE_WITHDRAE_BACK => '提现退款',
		self::TYPE_VIEW_COMISSION => '浏览佣金'
	];


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
